package com.blog.cloud.monitor.vo;

import cn.hutool.system.oshi.CpuInfo;
import cn.hutool.system.oshi.OshiUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * CPU信息对象
 */
@Getter
@Setter
public class CpuVO {

    /**
     * CPU型号
     */
    private String cpuModel;

    /**
     * 核心数
     */
    private int cpuNum;

    /**
     * CPU总的使用率
     */
    private double total;

    /**
     * CPU系统使用率
     */
    private double sys;

    /**
     * CPU用户使用率
     */
    private double used;

    /**
     * CPU当前等待率
     */
    private double wait;

    /**
     * CPU当前空闲率
     */
    private double free;

    public CpuVO() {
        // 获取CPU相关信息
        CpuInfo cpuInfo = OshiUtil.getCpuInfo();
        this.setCpuModel(cpuInfo.getCpuModel().split("\n")[0]);
        this.setCpuNum(cpuInfo.getCpuNum());
        this.setTotal(cpuInfo.getToTal());
        this.setSys(cpuInfo.getSys());
        this.setUsed(cpuInfo.getUsed());
        this.setWait(cpuInfo.getWait());
        this.setFree(cpuInfo.getFree());
    }
}
